package com.hoyue.servlet;


import com.hoyue.bean.*;
import com.hoyue.bean.Character;
import com.hoyue.service.*;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author Hoyue_network1
 * @version 1.0
 * Creat by 2018/8/28 8:48
 */

@WebServlet("/GetPageServlet")
public class GetPageServlet extends HttpServlet{

	CharacterService characterService = new CharacterService();
	InfoService infoService = new InfoService();
	VideoService videoService = new VideoService();
	IntroductionService introductionService = new IntroductionService();
	WorkDisplayService workDisplayService = new WorkDisplayService();
	DepartmentService departmentService = new DepartmentService();


	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		double randomNum = Math.random();
		request.setAttribute("randomNum", randomNum);

		List<Character> character = characterService.getAllChar();
		List<Info> info = infoService.getAllInfo();
		Video video = videoService.getVideo();
		List<Introduction> introduction = introductionService.getAllIntro();
		List<WorkDisplay> workDisplays = workDisplayService.getAllList();
		List<Department> departments = departmentService.getAllList();

		request.setAttribute("departments", departments);
		request.setAttribute("workDisplays", workDisplays);
		request.setAttribute("character",character);
		request.setAttribute("info",info);
		request.setAttribute("video",video);
		request.setAttribute("introduction",introduction);

		request.getRequestDispatcher("index.jsp").forward(request,response);
		return;
	}
}
